<template>
	<view class="content" style="width: 100%; height: 100%;">
		<view style="display: flex;background-color: #fff;width: calc(100% - 30rpx);padding: 50rpx 0;margin:auto 15rpx;
		align-items: center;justify-content: center;">
			<view style="width: 200rpx;" v-if="collectCodeData.length >0">
				<view style="text-align: center;font-size: 24rpx;font-weight: bold;">采集项代码</view>
				<view v-for="(item,index) in collectCodeData" :key="index">
					<input type="text" class="inputText" v-model="item.code">
				</view>
			</view>
			<view style="width: 200rpx; margin-left: 20rpx;" v-if="collectNameData.length >0">
				<view style="text-align: center;font-size: 24rpx;font-weight: bold;">采集项名称</view>
				<view v-for="(item,index) in collectNameData" :key="item.id">
					<input type="text" class="inputText" v-model="item.name">
				</view>
			</view>
		</view>
		
	</view>
</template>

<script>
	export default {
		components: {
			
		},
		data() {
			return {
				collectCodeData:[],//采集项代码
				collectNameData: [],//采集项名称
			}
		},
		methods: {
			getCollectMaintenance(){
				uni.showLoading({title: '数据加载中...',mask: true})
				this.$http.get('/api/v1/collectionItem/list',{}, true).then(res => {
					if (res.success == true) {
						if(res.data.items.length >0){
							let data = res.data.items
							data.forEach(item => {
							   this.collectCodeData.push({code:item.code})
							   this.collectNameData.push({name:item.name})
							})
						}
					} else {
						uni.showToast({title: res.msg,icon: 'none'});
					}
				}).catch(err => {
					uni.showToast({title: err.msg,icon: 'none'});
				})
			}
		},
		onLoad(e) { //页面加载完执行
			this.getCollectMaintenance()
		},
		onShow() { //每次进入页面执行

		}
	}
</script>

<style lang="scss">
	page {
		width: 100%;
		height: 100%;
		margin: 0;
		padding: 0;
		// background-color: #fff;
		// overflow-y: scroll;
	}
	.inputText{
	    min-height: 60rpx;
	    border: 1rpx solid #dadbde;
	    font-size: 24rpx;
	    padding:0 10rpx;
	    border-radius: 8rpx;
	    margin-top: 10rpx;
	}
</style>